package com.config;

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.io.ClassPathResource;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration   //表示 这个类 里面的符合spring 注解规范的对象都要生成
@ComponentScan("com") //扫描指定包下面 符合spring 注解规范的对象
@EnableWebMvc
@Import({WebConfig.class, JdbcConfig.class, MyBatisConfig.class})
public class SpringConfig extends WebMvcConfigurationSupport {
    @Bean("propertyConfigurer")  //propertie的配置器将指定的properies添加
    public PropertyPlaceholderConfigurer getPropertyPalce(){
        PropertyPlaceholderConfigurer propertyPlaceholderConfigurer = 	new PropertyPlaceholderConfigurer();//生成配置类
        //生成资源数组
        ClassPathResource[]  classPathResources = {new ClassPathResource("c3p0.properties")
        };
        //classpth就是部署出来的classes的根目录
        propertyPlaceholderConfigurer.setLocations(classPathResources);//将指定资源注册加载
        return propertyPlaceholderConfigurer;
    }

}
